package com.admin.admindemo.aop;

import com.admin.admin_util.exception.NoAuthorityException;
import com.admin.admin_util.exception.NotLoginException;
import com.admin.admindemo.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 陈群矜
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(NotLoginException.class)
    public Result<?> handleNotLogin() {
        return new Result<>(800002, "未登录");
    }

    @ExceptionHandler(NoAuthorityException.class)
    public Result<?> handleNoAuthority() {
        return new Result<>(800003, "无权限");
    }

    @ExceptionHandler(RuntimeException.class)
    public Result<?> handleSystemException() {
        return new Result<>(900000, "服务异常");
    }

}
